home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Reference / the cmsp digests ('94-'97) / csmp digest Vol 4 No 026 < prev    next >
Text File  |  1996-12-15  |  52KB  |  1,527 lines

  1. C.S.M.P. Digest             Tue, 26 Nov 96       Volume 4 : Issue 26
  2.  
  3. Today's Topics:
  4.  
  5.         Algorithms for Lighting effects
  6.         Changing a resource size
  7.         Playing .WAV files
  8.         Program crashes when calling LUpdate!
  9.         RegionToBitmap?
  10.         Saving Linked Lists
  11.         Sending Data via TCP
  12.         [Q] Editor for *huge* text files
  13.         copybits problem
  14.  
  15.  
  16.  
  17. The Comp.Sys.Mac.Programmer Digest is moderated by Mark Aiken
  18. (marka@ee.mcgill.ca).
  19.  
  20. The digest is a collection of article threads from the internet
  21. newsgroups comp.sys.mac.programmer.help, csmp.tools, csmp.misc and
  22. csmp.games. It is designed for people who read news semi-regularly and
  23. want an archive of the discussions.  If you don't know what a
  24. newsgroup is, you probably don't have access to it. Ask your systems
  25. administrator(s) for details. If you don't have access to news, you
  26. may still be able to post messages to the group by using a mail server
  27. like anon.penet.fi (mail help@anon.penet.fi for more information).
  28.  
  29. Each issue of the digest contains one or more sets of articles (called
  30. threads), with each set corresponding to a 'discussion' of a particular
  31. subject.  The articles are not edited; all articles included in this digest
  32. are in their original posted form (as received by our news server at
  33. ee.mcgill.ca).  Article threads are not added to the digest until the last
  34. article added to the thread is at least two weeks old (this is to ensure that
  35. the thread is dead before adding it to the digest).  Article threads that
  36. consist of only one message are generally not included in the digest.
  37.  
  38. The digests can be obtained by email, ftp or through the World Wide Web.
  39.  
  40. If you want to receive the digest by mail, send email to 
  41. majordomo@ee.mcgill.ca with no subject and one of the following commands
  42. as body:
  43.  
  44.     help                        Sends you a summary of commands
  45.     subscribe csmp                      Adds you to the mailing list
  46.     unsubscribe csmp                    Removes you from the list
  47.  
  48. Once you have subscribed, you will automatically receive each new
  49. issue as it is created.
  50.  
  51. Back issues are available by ftp from Info-Mac mirror sites in the
  52. per/csmp subdirectory, e.g.
  53.  
  54.   ftp://sumex-aim.stanford.edu/info-mac/per/csmp/
  55.  
  56. The contents of all back issues can be searched by accessing the
  57. following URL, courtesy of Andrew Barry (ajbarry@ozemail.com.au):
  58.  
  59.     http://marvin.stattech.com.au/search.html
  60.  
  61. They can also be searched through the following URLs, thanks to
  62. Tim Tuck (Tim.Tuck@sensei.com.au):
  63.  
  64.     http://wais.sensei.com.au/searchform.html
  65.     wais://wais.sensei.com.au:210/csmp?
  66.  
  67. -------------------------------------------------------
  68.  
  69. >From Dirk Johnson <dbj@apple.com>
  70. Subject: Algorithms for Lighting effects
  71. Date: Tue, 12 Nov 1996 17:43:50 -0800
  72. Organization: Apple
  73.  
  74. I was wondering if anyone could point me to any algorithms or examples
  75. that show how to do lighting effects on colors.  For example, if a
  76. person carrying a candle walks into a dark room, what algorithm would be
  77. used to brighten the colors?
  78.  
  79. Any help is appreciated.
  80.  
  81. Dirk Johnson
  82.  
  83. +++++++++++++++++++++++++++
  84.  
  85. >From brgames@aol.com
  86. Date: 14 Nov 1996 01:41:52 GMT
  87. Organization: AOL http://www.aol.com
  88.  
  89. >>
  90. I am not sure what exactly you want. For lighting a lot of people use a
  91. shade table which is a 2d array with 1 index being the color and the
  92. second being the intensity.
  93. <<
  94.  
  95. What do you do for 16-bit?  Same thing, but with a larger array, sort of
  96. like an inverse color table map?  Would the right-shifting (to reduce a
  97. 16-bit color to the table resolution) and the table lookups really be
  98. faster than the intensity multiplication?
  99.  
  100. Hmmmm.....
  101.  
  102. Mike.
  103. +-----------------------------------------------------------+
  104. | Michael A. Kelly                        Eidos Interactive |
  105. | Senior Software Engineer    1825 Trousdale Drive, Suite B |
  106. | mkelly@eidos.com                     Burlingame, CA 94010 |
  107. | http://www.eidos.com                  (415) 652-1200 x115 |
  108. +-----------------------------------------------------------+
  109.  
  110. +++++++++++++++++++++++++++
  111.  
  112. >From David Matiskella <matiskel@aa.washington.edu>
  113. Date: Wed, 13 Nov 1996 18:30:04 -0800
  114. Organization: University of Washington
  115.  
  116. On 14 Nov 1996 brgames@aol.com wrote:
  117.  
  118. > >>
  119. > I am not sure what exactly you want. For lighting a lot of people use a
  120. > shade table which is a 2d array with 1 index being the color and the
  121. > second being the intensity.
  122. > <<
  123. > What do you do for 16-bit?  Same thing, but with a larger array, sort of
  124. > like an inverse color table map?  Would the right-shifting (to reduce a
  125. > 16-bit color to the table resolution) and the table lookups really be
  126. > faster than the intensity multiplication?
  127. > Hmmmm.....
  128. > Mike.
  129. > +-----------------------------------------------------------+
  130. > | Michael A. Kelly                        Eidos Interactive |
  131. > | Senior Software Engineer    1825 Trousdale Drive, Suite B |
  132. > | mkelly@eidos.com                     Burlingame, CA 94010 |
  133. > | http://www.eidos.com                  (415) 652-1200 x115 |
  134. > +-----------------------------------------------------------+
  135. Depends what you are doing. If you image has less than 256 colors you can
  136. give each image its own 16 bit color table. Color tables are sort of cool
  137. since you can easily add things like blinking lights, lights unaffected by
  138. shading, and so on.
  139.     You can also do tablelook ups. With 16 bit 16 bit would be huge
  140. you could do the look up on each 5 bit component. Its rather expensive
  141. costing 3 instructions to extract the color, 3 loads to shade the pixel, 2
  142. instructions to reassemble the pixel and 1 to write it out.  On a 604
  143. multiplication is probaly as fast as table look ups
  144.  
  145. David Matiskella
  146. matiskel@aa.washington.edu
  147.  
  148.  
  149.  
  150. ---------------------------
  151.  
  152. >From Benoit Grange <ben@oleane.net>
  153. Subject: Changing a resource size
  154. Date: 13 Nov 1996 19:09:56 +0100
  155. Organization: Guest of OLEANE - PIPEX International
  156.  
  157.  
  158. I have a problem changing a resource Size, ie:
  159.  
  160.     Handle h = GetResource('blob', 128); // We should check
  161.     long   size = GetHandleSize(h); // We should check
  162.  
  163.     size += 64;
  164.  
  165.     SetHandleSize(h, size);
  166.  
  167.     if (ResError())
  168.         Debugger();
  169.  
  170. I always get a -111 error (operating on a free block).
  171.  
  172. Is this the correct way to do it ?
  173.  
  174. -- 
  175. Benoit Grange - OLEANE Network Operations Center
  176.  
  177. Support technique et operationnel Oleane :  support@oleane.net
  178. Informations commerciales sur Oleane     :  info@oleane.net
  179.  
  180. Computers run on smoke, when the smoke goes out, computers stop working...
  181.  
  182. +++++++++++++++++++++++++++
  183.  
  184. >From franke1@llnl.gov (Norman Franke)
  185. Date: Wed, 13 Nov 1996 13:37:31 -0800
  186. Organization: Lawrence Livermore National Laboratory
  187.  
  188. In article <u3k9rphnnv.fsf@vaudoo.oleane.net>, Benoit Grange
  189. <ben@oleane.net> wrote:
  190.  
  191. >         SetHandleSize(h, size);
  192. > I always get a -111 error (operating on a free block).
  193.  
  194. Use SetResourceSize instead.
  195.  
  196. -- 
  197. Norman Franke
  198. franke1@llnl.gov
  199.  
  200. ---------------------------
  201.  
  202. >From werdna@cyberjunkie.com (Andrew Wright)
  203. Subject: Playing .WAV files
  204. Date: Tue, 12 Nov 1996 15:47:29 +1000
  205. Organization: Prentice Centre, University of Queensland
  206.  
  207. Hi all. I was wondering could anyone point me towards some info on playing
  208. .wav files on the Mac? (Obviously, I mean adding this functionality to my
  209. app, not just playing them! :) Even better, is there a share/free ware
  210. library out there? Thanks very much.
  211.  
  212. -- 
  213. Regards,               |         Visit me on-line
  214. Andrew Wright          |                at
  215. werdna@cyberjunkie.com | http://student.uq.edu.au/~s341797
  216.  
  217. +++++++++++++++++++++++++++
  218.  
  219. >From reekes@apple.com (Jim Reekes)
  220. Date: Wed, 13 Nov 1996 17:35:43 -0800
  221. Organization: Apple Computer, Inc.
  222.  
  223. In article <werdna-ya023180001211961547290001@news.uq.edu.au>,
  224. werdna@cyberjunkie.com (Andrew Wright) wrote:
  225.  
  226. > Hi all. I was wondering could anyone point me towards some info on playing
  227. > .wav files on the Mac? (Obviously, I mean adding this functionality to my
  228. > app, not just playing them! :) Even better, is there a share/free ware
  229. > library out there? Thanks very much.
  230.  
  231. Using the latest QuickTime 2.5, you just open the .wav file using
  232. MoviePlayer and will will play the file just as any other movie file. The
  233. conversion is automatically done in real time. You can also export the
  234. file to another Mac format while within MoviePlayer.
  235.  
  236. Jim
  237.  
  238. -- 
  239. Jim Reekes, Polterzeitgeist |       QuickTime Products R&D
  240.                             |        Sound Manager Expert
  241. Apple Computer, Inc.        | "All opinions expressed are mine, and
  242. 2 Infinite Loop  MS 302-3KS |  do not necessarily represent those
  243. Cupertino, CA 95014         |  of my employer, Apple Computer Inc."
  244.  
  245. ---------------------------
  246.  
  247. >From Anders.Wahlin@hum.gu.se (Anders Wahlin)
  248. Subject: Program crashes when calling LUpdate!
  249. Date: Thu, 07 Nov 1996 10:04:37 +0100
  250. Organization: HDS
  251.  
  252. Hello.
  253.  
  254. I have a dialog with a list in it. In my dialog filter function I call
  255. LUpdate on every update event, like this:
  256.  
  257. [snip]
  258.   
  259.  if (theEvent->what == updateEvt) {
  260.       SetPort(theDialog);
  261.       DrawOutlinedButton(theDialog, 1);
  262.       if (resultList != nil) {
  263.          LUpdate((*resultList)->port->visRgn, resultList); /* CRASH */
  264.       }
  265.       FrameRect (&resultListRect);
  266.    }
  267.  
  268. [snip]
  269.  
  270. When the dialog is called the first time everything works fine. The
  271. problem comes when I show another dialog above the list dialog and then
  272. then return to it. Then the program crashes.
  273.  
  274. Any clues?
  275.  
  276. Thanks you
  277.  
  278. +++++++++++++++++++++++++++
  279.  
  280. >From bilewicz@helf4.physik.fu-berlin.de (Roger Bilewicz)
  281. Date: 8 Nov 96 16:56:15 GMT
  282. Organization: Freie Universitaet Berlin
  283.  
  284. Anders.Wahlin@hum.gu.se (Anders Wahlin) writes:
  285.  
  286. >Hello.
  287.  
  288. >I have a dialog with a list in it. In my dialog filter function I call
  289. >LUpdate on every update event, like this:
  290.  
  291. >[snip]
  292. >  
  293. > if (theEvent->what == updateEvt) {
  294. >      SetPort(theDialog);
  295. >      DrawOutlinedButton(theDialog, 1);
  296. >      if (resultList != nil) {
  297. >         LUpdate((*resultList)->port->visRgn, resultList); /* CRASH */
  298. >      }
  299. >      FrameRect (&resultListRect);
  300. >   }
  301.  
  302. >[snip]
  303.  
  304. >When the dialog is called the first time everything works fine. The
  305. >problem comes when I show another dialog above the list dialog and then
  306. >then return to it. Then the program crashes.
  307.  
  308. >Any clues?
  309.  
  310. Hi Anders,
  311. you should check if DialogPtr(theEvent.message) = myDialog when you get
  312. an update event. When your code crashes, the update is most probably
  313. targeted to a different window. Nevertheless, you should update that
  314. window rather than to ignore the event!
  315.  
  316. Hope it helps,
  317. Roger
  318.  
  319.  
  320. +++++++++++++++++++++++++++
  321.  
  322. >From bboppie@aol.com
  323. Date: 13 Nov 1996 23:25:05 GMT
  324. Organization: AOL http://www.aol.com
  325.  
  326. >>I have a dialog with a list in it. In my dialog filter function I call
  327. LUpdate on every update event, like this:
  328.  
  329. [snip]
  330.   
  331.  if (theEvent->what == updateEvt) {
  332.       SetPort(theDialog);
  333.       DrawOutlinedButton(theDialog, 1);
  334.       if (resultList != nil) {
  335.          LUpdate((*resultList)->port->visRgn, resultList); /* CRASH */
  336.       }
  337.       FrameRect (&resultListRect);
  338.    }
  339.  
  340. [snip]
  341.  
  342. When the dialog is called the first time everything works fine. The
  343. problem comes when I show another dialog above the list dialog and then
  344. then return to it. Then the program crashes.
  345.  
  346. Any clues?<<
  347.  
  348. The best way to handle updating the List in your dialog would be to write
  349. your own dialog hook. 
  350.  
  351. SInt16 YourSmallDLOG(DialogRef theDialog, EventRecord *theEvent, SInt16
  352. item)
  353. {
  354.     // Handle your items here and the return false on everything else
  355. so the dialog mgr
  356.       // will update the rest. I'd look in Inside Macintosh Essential
  357. Tools for more info.
  358.       return false;
  359. }
  360.  
  361. BBoppie
  362.  
  363.  
  364.  
  365.  
  366.  
  367. ---------------------------
  368.  
  369. >From "Aidan Cully" <aidan@xanadu.kublai.com>
  370. Subject: RegionToBitmap?
  371. Date: 29 Oct 96 13:43:17 -0400
  372. Organization: INTAC Access Corporation - An Internet Service Provider
  373.  
  374. Hello, I'm writing a program which makes use of Offscreen Graphics Worlds
  375. for drawing into multiple windows, but the problem would most likely also
  376. exist in scenarios where there is more than one window on the screen.
  377.  
  378. The problem is that CopyBits seems to expect a window that it's drawing
  379. into to be uncovered by any other window.  Fine, so we use CopyMask to clip
  380. to the window's shape.  But CopyMask expects a BitMap, while the Window's
  381. visRgn is a Region.  Is there any RegionToBitmap sort of function I could
  382. use to generate the proper mask for CopyMask?
  383.  
  384. The solution I have come up with requires the creation of a new GWorld
  385. (with bit-depth of 1), setting the clipRgn for that world to be the
  386. window's visRgn and filling the portRect, but this is a very clumsy hack. 
  387. Anyone know a better way?
  388.  
  389. Thanks in advance
  390. --aidan
  391. --
  392. You can't find your waitress
  393.     With a geiger counter
  394. She hates you and your friends and you just
  395.     Can't get served without her
  396.         --Tom Waits
  397.  
  398.  
  399.  
  400. +++++++++++++++++++++++++++
  401.  
  402. >From "Aidan Cully" <aidan@xanadu.kublai.com>
  403. Date: 29 Oct 96 16:14:25 -0400
  404. Organization: INTAC Access Corporation - An Internet Service Provider
  405.  
  406. >Hello, I'm writing a program which makes use of Offscreen Graphics Worlds
  407. >for drawing into multiple windows, but the problem would most likely also
  408. >exist in scenarios where there is more than one window on the screen.
  409. >
  410. >The problem is that CopyBits seems to expect a window that it's drawing
  411. >into to be uncovered by any other window.  Fine, so we use CopyMask to
  412. clip
  413. >to the window's shape.  But CopyMask expects a BitMap, while the Window's
  414. >visRgn is a Region.  Is there any RegionToBitmap sort of function I could
  415. >use to generate the proper mask for CopyMask?
  416.  
  417. Answered my own question.. or rather solved the problem that led to my
  418. question. The problem was that I was drawing to the graphics port that
  419. existed when the application was started, instead of the window's own 
  420. graphics port.  Still, BeginUpdate( window ) should force the current
  421. graphics port to be "window".  And there really should be a
  422. RegionToBitmap() function.
  423.  
  424. Thanks anyway to anyone who had the chance to respond.
  425. --aidan
  426.  
  427.  
  428.  
  429. +++++++++++++++++++++++++++
  430.  
  431. >From msoori@genetics.bio-rad.com (msoori)
  432. Date: Wed, 30 Oct 1996 16:14:34 GMT
  433. Organization: Bio-Rad Laboratories
  434.  
  435. CopyBits() uses the srcBits and destBits, which can either be bitmaps or
  436. pixMaps as well as a region that is used as a mask to clip to the shape of
  437. the given region.  What CopyMask does is to use a bit map as a mask
  438. instead of a region.  BitMapToRegion() does convert a bitmap to a region,
  439. but I dont think there is anything to go the otherway (also there is a bug
  440. in the PowerMac with this function - gives you a bigger region than the
  441. actual).
  442.  
  443. Either way, the window should still be uncovered, or else you wil be
  444. drawing over the other windows as well.  If you are trying to avoid this,
  445. I guess, what you could do is to use CopyBits() with the visRgn of that
  446. window as the mask region.
  447.  
  448. Good Luck.
  449.  
  450. In article <AE9BBA7A-8E3DC@199.173.0.243>, "Aidan Cully"
  451. <aidan@xanadu.kublai.com> wrote:
  452.  
  453. > Hello, I'm writing a program which makes use of Offscreen Graphics Worlds
  454. > for drawing into multiple windows, but the problem would most likely also
  455. > exist in scenarios where there is more than one window on the screen.
  456. > The problem is that CopyBits seems to expect a window that it's drawing
  457. > into to be uncovered by any other window.  Fine, so we use CopyMask to clip
  458. > to the window's shape.  But CopyMask expects a BitMap, while the Window's
  459. > visRgn is a Region.  Is there any RegionToBitmap sort of function I could
  460. > use to generate the proper mask for CopyMask?
  461. > The solution I have come up with requires the creation of a new GWorld
  462. > (with bit-depth of 1), setting the clipRgn for that world to be the
  463. > window's visRgn and filling the portRect, but this is a very clumsy hack. 
  464. > Anyone know a better way?
  465. > Thanks in advance
  466. > --aidan
  467. > --
  468. > You can't find your waitress
  469. >     With a geiger counter
  470. > She hates you and your friends and you just
  471. >     Can't get served without her
  472. >         --Tom Waits
  473.  
  474. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  475. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  476. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  477.  
  478. +++++++++++++++++++++++++++
  479.  
  480. >From Carl R. Osterwald <carl_osterwald@nrel.gov>
  481. Date: 30 Oct 1996 15:50:17 GMT
  482. Organization: National Renewable Energy Laboratory
  483.  
  484. In article <AE9BDDE9-4FC92@199.173.0.243> Aidan Cully,
  485. aidan@xanadu.kublai.com writes:
  486.  
  487. >>But CopyMask expects a BitMap, while the Window's
  488. >>visRgn is a Region.  Is there any RegionToBitmap sort of function I could
  489. >>use to generate the proper mask for CopyMask?
  490.  
  491. That's easy--just use PaintRegion().  Set the current port to your
  492. offscreen GWorld and call PaintRegion().
  493.  
  494. >Answered my own question.. or rather solved the problem that led to my
  495. >question. The problem was that I was drawing to the graphics port that
  496. >existed when the application was started, instead of the window's own 
  497. >graphics port.  Still, BeginUpdate( window ) should force the current
  498. >graphics port to be "window".
  499.  
  500. Applications have the responsibility of maintaining and knowing which
  501. port they are drawing into.  Quickdraw has been this way since about
  502. 1982.
  503.  
  504. >And there really should be a
  505. >RegionToBitmap() function.
  506.  
  507. There is, see above.
  508.  
  509. +++++++++++++++++++++++++++
  510.  
  511. >From russotto@wanda.vf.pond.com (Matthew T. Russotto)
  512. Date: 2 Nov 1996 12:54:12 -0500
  513. Organization: Ghotinet
  514.  
  515. In article <msoori-3010960814330001@ms.genetics.bio-rad.com>,
  516. msoori <msoori@genetics.bio-rad.com> wrote:
  517. }CopyBits() uses the srcBits and destBits, which can either be bitmaps or
  518. }pixMaps as well as a region that is used as a mask to clip to the shape of
  519. }the given region.  What CopyMask does is to use a bit map as a mask
  520. }instead of a region.  BitMapToRegion() does convert a bitmap to a region,
  521. }but I dont think there is anything to go the otherway (also there is a bug
  522. }in the PowerMac with this function - gives you a bigger region than the
  523. }actual).
  524.  
  525. RegionToBitmap is a.k.a PaintRgn.  Well, not quite-- you create an 
  526. old-style GrafPort and a Bitmap the size of the bounding box of the
  527. region, and then PaintRgn into it.  The Grafport can then be trashed.
  528.  
  529. -- 
  530. Matthew T. Russotto                                russotto@pond.com
  531. "Extremism in defense of liberty is no vice, and moderation in pursuit
  532. of justice is no virtue." 
  533.  
  534. +++++++++++++++++++++++++++
  535.  
  536. >From dkj@apple.com (Dave Johnson)
  537. Date: Sat, 02 Nov 1996 13:03:49 -0800
  538. Organization: Apple Computer, Inc.
  539.  
  540. In article <55g1s4$2h9@wanda.vf.pond.com>, russotto@wanda.vf.pond.com
  541. (Matthew T. Russotto) wrote:
  542.  
  543. > RegionToBitmap is a.k.a PaintRgn.  Well, not quite-- you create an 
  544. > old-style GrafPort and a Bitmap the size of the bounding box of the
  545. > region, and then PaintRgn into it.  The Grafport can then be trashed.
  546. > -- 
  547. > Matthew T. Russotto                                russotto@pond.com
  548. > "Extremism in defense of liberty is no vice, and moderation in pursuit
  549. > of justice is no virtue." 
  550.  
  551.  Why not just use the region directly?: use plain old CopyBits with a
  552. maskRgn instead of copyMask. Apparently it's often even faster than
  553. CopyMask...
  554.  
  555. Dave Johnson
  556. dkj@apple.com
  557.  
  558. +++++++++++++++++++++++++++
  559.  
  560. >From mattd@gcsf.com (Matt Deatherage)
  561. Date: Mon, 04 Nov 1996 00:56:21 -0600
  562. Organization: GCSF, Incorporated
  563.  
  564. In article <AE9BBA7A-8E3DC@199.173.0.243>, "Aidan Cully"
  565. <aidan@xanadu.kublai.com> wrote:
  566.  
  567. > The problem is that CopyBits seems to expect a window that it's drawing
  568. > into to be uncovered by any other window.  Fine, so we use CopyMask to clip
  569. > to the window's shape.  But CopyMask expects a BitMap, while the Window's
  570. > visRgn is a Region.  Is there any RegionToBitmap sort of function I could
  571. > use to generate the proper mask for CopyMask?
  572.  
  573. I'm missing something basic here, I think.
  574.  
  575. When you call CopyBits to a window's grafPort, the Window Manager should
  576. already have set the visRgn to only the visible portion of the window. 
  577. Since drawing is restricted to the intersection of the clipRgn and visRgn,
  578. CopyBits to a window should never draw outside a window's content area
  579. unless you've messed with the visRgn (a bad idea for windows, but fine for
  580. your own off-screen grafPorts or GWorlds).
  581.  
  582. That said, getting a bitmap from a region is simple -- make an offscreen
  583. grafPort with a bitmap attached and call PaintRgn or FillRgn, and you're
  584. done.  You shouldn't need to do this for the problem you mention as I read
  585. it, though.
  586.  
  587. - --------------------------------------------------------------------------
  588. Matt Deatherage                                      <mailto:mattd@gcsf.com>
  589. GCSF, Incorporated                                     <http://www.gcsf.com>
  590.  
  591. +++++++++++++++++++++++++++
  592.  
  593. >From michel@dcm.sat.fr (Michel Pollet)
  594. Date: Wed, 6 Nov 1996 20:17:12 +0100
  595. Organization: SAT/SAGEM
  596.  
  597. Dave Johnson <dkj@apple.com> wrote:
  598.  
  599. >  Why not just use the region directly?: use plain old CopyBits with a
  600. > maskRgn instead of copyMask. Apparently it's often even faster than
  601. > CopyMask...
  602.  
  603. Remember to sect it to the visible region of the window itself, because
  604. if you don't, you'll have little bits of control strips and other
  605. floatings drawn uppon..
  606.  
  607. --
  608. Michel Pollet                       Macintosh developer & MkLinux hacker
  609. Email: michel@dcm.sat.fr                        Phone: +33 1 55 75 14 23
  610. http://www.inforoute.cgs.fr/pollet/      <-- Have a look at my guitars !
  611.  
  612. +++++++++++++++++++++++++++
  613.  
  614. >From dkj@apple.com (Dave Johnson)
  615. Date: Wed, 06 Nov 1996 11:45:15 -0800
  616. Organization: Apple Computer, Inc.
  617.  
  618. In article <mattd-0411960056220001@pri5-02.ionet.net>, mattd@gcsf.com
  619. (Matt Deatherage) wrote:
  620.  
  621. > In article <AE9BBA7A-8E3DC@199.173.0.243>, "Aidan Cully"
  622. > <aidan@xanadu.kublai.com> wrote:
  623. > > The problem is that CopyBits seems to expect a window that it's drawing
  624. > > into to be uncovered by any other window.  Fine, so we use CopyMask to clip
  625. > > to the window's shape.  But CopyMask expects a BitMap, while the Window's
  626. > > visRgn is a Region.  Is there any RegionToBitmap sort of function I could
  627. > > use to generate the proper mask for CopyMask?
  628. > I'm missing something basic here, I think.
  629. <SNIP>
  630. > ----------------------------------------------------------------------------
  631. > Matt Deatherage                                      <mailto:mattd@gcsf.com>
  632. > GCSF, Incorporated                                     <http://www.gcsf.com>
  633.  
  634. Aha! Yes, Matt is absolutely right, I missed the original post and only
  635. saw the last bit, about wanting to use copyMask but having a region. 
  636.  
  637. Sounds to me like the problem is simply that you never called SetPort to
  638. set the surrent grafport to the window in question. Simply doing that
  639. automatically clips copybits (and any other QuickDraw drawing) to the
  640. visible contents of the window.
  641.  
  642. Dave Johnson
  643.  
  644. +++++++++++++++++++++++++++
  645.  
  646. >From "Jim Cushing" <jcushing@grove.ufl.edu>
  647. Date: Wed, 13 Nov 1996 15:32:01 -0500
  648. Organization: University of Florida
  649.  
  650. I sent a message to the original author, but not to the newsgroup concerning
  651. this problem, and it turned out that my response solved the author's
  652. problem.  So I guess I ought to share it with the rest of the world.
  653.  
  654. The problem was, CopyBits() only clips to the visible region of the active
  655. port.  If you wish to copy to a window that is not the front window, you
  656. must first SetPort() to the window you wish to CopyBits() to.  Note that
  657. SetPort() does not activate, select, or bring to front any window, it just
  658. makes it the active grafPort.
  659.  
  660. ---------------------------
  661.  
  662. >From amcclain@il-icom.net (Andrew McClain)
  663. Subject: Saving Linked Lists
  664. Date: Fri, 08 Nov 1996 11:32:03 -0500
  665. Organization: Illinois Internet Communications, Inc.
  666.  
  667. How do I save a variable length double linked list to a resource file?
  668.  
  669. Here is my record structure:
  670.  
  671. typedef struct LinkRec
  672. {
  673.    OSType         fileType;
  674.    OSType         creator;
  675.    FSSpec         destination;
  676.    Boolean        defaultRec;
  677.    struct LinkRec *prefRec, *nextRec;  /* Double Linked List */
  678. } LinkRec, *LinkRecPtr;
  679.  
  680. Thank you for any replies.
  681.  
  682. Sincerely,
  683. Andrew McClain
  684.  
  685. +++++++++++++++++++++++++++
  686.  
  687. >From DavidO@dascorp.com (David Phillip Oster)
  688. Date: 8 Nov 1996 21:51:49 GMT
  689. Organization: Digital Arts & Sciences Corp.
  690.  
  691. In article <amcclain-0811961132030001@206.62.101.72>, amcclain@il-icom.net
  692. (Andrew McClain) wrote:
  693.  
  694. >How do I save a variable length double linked list to a resource file?
  695.  
  696. >Here is my record structure:
  697.  
  698. >typedef struct LinkRec
  699. >{
  700. >   OSType         fileType;
  701. >   OSType         creator;
  702. >   FSSpec         destination;
  703. >   Boolean        defaultRec;
  704. >   struct LinkRec *prefRec, *nextRec;  /* Double Linked List */
  705. >} LinkRec, *LinkRecPtr;
  706.  
  707. The resource map of a resource file has a limit of roughly 2000 entities.
  708. Since this is rather small, you'd do best to do something like the following
  709.  
  710. write:
  711.  
  712.    h = NewHandle(0);
  713.    for(p = fistLink; nil != p ; p = p->nextRec){
  714.       if(noErr != (errCode = PtrToHand(p, h, sizeof(LinkRec)))){
  715.          DisposeHandle(h);
  716.          return errCode;
  717.       }
  718.    }
  719.    AddResource(h, 'Link', 128, "\p");
  720.    if(noErr != (errCode = ResError())){
  721.       DisposeHandle(h); // if it was good, resource manager now owns handle
  722.    }
  723.    return errCode;
  724.  
  725. read:
  726.    h = GetResource('Link', 128);
  727.    HLock(h);
  728.    size = GetHandleSize(h);
  729.    p = (LinkRecPtr) *h;
  730.  
  731.    for( ; size > 0; size -= sizeof(LinkRec), p++){
  732.       ... left as an exercise: make a copy of p, link it in.
  733.    }
  734.    HUnlock(h);
  735.    HPurge(h);
  736.  
  737. -- 
  738. -- Warning: no attempt has been made to verify that the sender is actually David Oster
  739. Give a man a fish: feed him for a day. Teach a man to fish: feed him for life.
  740. Teach a hundred men to fish: deplete the fish stock, destroy an ecosystem.
  741.  
  742. +++++++++++++++++++++++++++
  743.  
  744. >From jeff@purple.com (Jeff Abrahamson)
  745. Date: Sun, 10 Nov 1996 11:00:47 -0600
  746. Organization: PDI
  747.  
  748. In article <amcclain-0811961132030001@206.62.101.72>, amcclain@il-icom.net
  749. (Andrew McClain) wrote:
  750.  
  751. > How do I save a variable length double linked list to a resource file?
  752. > Here is my record structure:
  753. > typedef struct LinkRec
  754. > {
  755. >    OSType         fileType;
  756. >    OSType         creator;
  757. >    FSSpec         destination;
  758. >    Boolean        defaultRec;
  759. >    struct LinkRec *prefRec, *nextRec;  /* Double Linked List */
  760. > } LinkRec, *LinkRecPtr;
  761. > Thank you for any replies.
  762.  
  763. Presumably you'll read the linked list back into RAM before using it
  764. again. In that case, you can skip the pointers and stream it out:
  765.  
  766. write:
  767.  
  768.    // instatiate a stream
  769.    item = first_item_in_list();
  770.    do {
  771.       stream.write(item->fileType);
  772.       stream.write(item->creator);
  773.       stream.write(item->destination);
  774.       stream.write(item->defaultRec);
  775.    } while(item = next_item_in_list());
  776.    // flush stream here
  777.  
  778. When you read it back in, you just recreate your pointers as you go:
  779.  
  780.    while(get_next_item_from_stream) {
  781.       link_item_into_list_at_end
  782.    }
  783.  
  784. // and define get_next_item_from_stream:
  785.    Item *item = new Item;
  786.    item->fileType = stream.read;
  787.    item->creator = stream.read;
  788.    // etc.
  789.    return(item);  // unless EOS, in which case delete item and return nil
  790.  
  791.  
  792. Note that the stream here could just be a handle that you've made big
  793. enough for the task. The point is that you use a linked list in RAM for
  794. certain properties of traversal and efficiency that you don't need the
  795. structure in the resource fork to have.
  796.  
  797. +++++++++++++++++++++++++++
  798.  
  799. >From David Gillies <daggilli@vader.brad.ac.uk>
  800. Date: Mon, 11 Nov 1996 20:38:32 +0000
  801. Organization: University of Bradford
  802.  
  803. Andrew McClain wrote:
  804. > How do I save a variable length double linked list to a resource file?
  805. > Here is my record structure:
  806. > typedef struct LinkRec
  807. > {
  808. >    OSType         fileType;
  809. >    OSType         creator;
  810. >    FSSpec         destination;
  811. >    Boolean        defaultRec;
  812. >    struct LinkRec *prefRec, *nextRec;  /* Double Linked List */
  813. > } LinkRec, *LinkRecPtr;
  814. > Thank you for any replies.
  815. If you have a limited number of entries in your list you could save
  816. your list entries out as a series of resources. You might want to
  817. make a meta-structure where the last entry is the resource IDs of the
  818. list entries instead of their addresses. A linked list is a lot easier
  819. to write to a file since it is a linear structure. N-ary trees are
  820. nasty (look at the stuff in IM IV on low-level volume info if you don't
  821. believe me). 
  822.  
  823. The above comes with the caveat that the Resource Manager is not a
  824. database. Read technote wossname in OS on (not) abusing your manager.
  825.  
  826.  
  827. -- 
  828. ______________________________________________________________________
  829. David A. G. Gillies                        (daggilli@vader.brad.ac.uk)
  830.       University of Bradford, Bradford, West Yorkshire, England
  831. _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  832.  
  833. +++++++++++++++++++++++++++
  834.  
  835. >From dBrandon@iadfw.net (Bryant Brandon)
  836. Date: Tue, 12 Nov 1996 20:45:56 -0600
  837. Organization: Anti Christian Coalition
  838.  
  839. In article <32878EC8.6450@vader.brad.ac.uk>, David Gillies
  840. <daggilli@vader.brad.ac.uk> wrote:
  841.  
  842. >Andrew McClain wrote:
  843. >> 
  844. >> How do I save a variable length double linked list to a resource file?
  845. >> 
  846. >> Here is my record structure:
  847. >> 
  848. >> typedef struct LinkRec
  849. >> {
  850. >>    OSType         fileType;
  851. >>    OSType         creator;
  852. >>    FSSpec         destination;
  853. >>    Boolean        defaultRec;
  854. >>    struct LinkRec *prefRec, *nextRec;  /* Double Linked List */
  855. >> } LinkRec, *LinkRecPtr;
  856. >> 
  857. >> Thank you for any replies.
  858. >> 
  859. >If you have a limited number of entries in your list you could save
  860. >your list entries out as a series of resources. You might want to
  861. >make a meta-structure where the last entry is the resource IDs of the
  862. >list entries instead of their addresses. A linked list is a lot easier
  863. >to write to a file since it is a linear structure. N-ary trees are
  864. >nasty (look at the stuff in IM IV on low-level volume info if you don't
  865. >believe me). 
  866. >
  867. >The above comes with the caveat that the Resource Manager is not a
  868. >database. Read technote wossname in OS on (not) abusing your manager.
  869. >
  870. >
  871. >-- 
  872. >______________________________________________________________________
  873. >David A. G. Gillies                        (daggilli@vader.brad.ac.uk)
  874. >      University of Bradford, Bradford, West Yorkshire, England
  875. >_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  876.  
  877.    Once I toyed with the idea of using a Handle to a resizeable block in
  878. memory.  The block is filled with little objects representing individual
  879. little links.  The pointers contained within the link objects are offsets
  880. from the beginning of the block(the haddle could be in a static variable
  881. called thisHandle).  With that setup, you could write the entire block
  882. into one resource and read it out again very easily.  You could use a
  883. container class to handle the block.
  884.    Just food for thought...
  885.  
  886. I'm usually only here on weekends.  If you really want me to see a reply, please mail it.
  887.  
  888. +++++++++++++++++++++++++++
  889.  
  890. >From tfischer@See.Address.In.Signature (Tim Fischer)
  891. Date: Wed, 13 Nov 1996 08:48:13 -0600
  892. Organization: Coda Music Technology
  893.  
  894. In article <carl.gustafson-1311960850290001@stelis.ece.drexel.edu>,
  895. carl.gustafson@no.spam.welcome (Carl Gustafson) wrote:
  896.  
  897. > In article <amcclain-0811961132030001@206.62.101.72>, amcclain@il-icom.net
  898. > (Andrew McClain) wrote:
  899. > > How do I save a variable length double linked list to a resource file?
  900. > > 
  901. > > Here is my record structure:
  902. > > 
  903. > > typedef struct LinkRec
  904. > > {
  905. > >    OSType         fileType;
  906. > >    OSType         creator;
  907. > >    FSSpec         destination;
  908. > >    Boolean        defaultRec;
  909. > >    struct LinkRec *prefRec, *nextRec;  /* Double Linked List */
  910. > > } LinkRec, *LinkRecPtr;
  911. > The simple answer is to start at the head, and use AddResource to put each
  912. > link in the file's resource fork. As you go along, just replace the link
  913. > pointers with the resource ID number (cast this number to a long, so that
  914. > it exactly fits in the place of the link pointers.)
  915. > The details (like duplicating links first, etc.) are left as an exercise :)
  916. > I won't comment on the pros and cons of doing this.
  917.  
  918. Am I missing something here?  
  919.  
  920. You don't need to store the link information when saving a linked list. 
  921. Just traverse the list, and save the data portion in any format you want
  922. to a (resource or data) file in the correct order.  When reloading the
  923. linked list, read in each node and add it to the tail of the list (which
  924. is trivial and efficient assuming your head node points to the tail
  925. (circular doubly-linked list).  If it's not circular, you can just keep
  926. track of the tail on your own-- it's the last node you've added.
  927.  
  928. Your add routine will take care of recreating the links as you rebuild the
  929. list, just as it did the first time you created the list.
  930.  
  931. -Tim
  932.  
  933. -- 
  934. - -------------------------------------
  935. Tim Fischer
  936.  
  937. The following email address is mangled to prevent automated
  938. unsolicited junk mail.  Replace the '_AT_' with an '@':
  939.  
  940. tfischer_AT_codamusic.com
  941.  
  942. +++++++++++++++++++++++++++
  943.  
  944. >From carl.gustafson@no.spam.welcome (Carl Gustafson)
  945. Date: Wed, 13 Nov 1996 08:50:29 -0500
  946. Organization: Imaging and Computer Vision Center, Drexel University
  947.  
  948. In article <amcclain-0811961132030001@206.62.101.72>, amcclain@il-icom.net
  949. (Andrew McClain) wrote:
  950.  
  951. > How do I save a variable length double linked list to a resource file?
  952. > Here is my record structure:
  953. > typedef struct LinkRec
  954. > {
  955. >    OSType         fileType;
  956. >    OSType         creator;
  957. >    FSSpec         destination;
  958. >    Boolean        defaultRec;
  959. >    struct LinkRec *prefRec, *nextRec;  /* Double Linked List */
  960. > } LinkRec, *LinkRecPtr;
  961.  
  962. The simple answer is to start at the head, and use AddResource to put each
  963. link in the file's resource fork. As you go along, just replace the link
  964. pointers with the resource ID number (cast this number to a long, so that
  965. it exactly fits in the place of the link pointers.)
  966.  
  967. The details (like duplicating links first, etc.) are left as an exercise :)
  968.  
  969. I won't comment on the pros and cons of doing this.
  970.  
  971. Carl
  972.  
  973. -- 
  974. Carl Gustafson
  975. carl.gustafson at ece.drexel.edu
  976. (busily trying to avoid spammers)
  977. Imaging and Computer Vision Center
  978. Drexel University, Philadelphia, Penna
  979. - ----------------------------------------------------------
  980. I don't speak for Drexel, and Drexel doesn't listen to me...
  981.  
  982. ---------------------------
  983.  
  984. >From edan@netcom.com
  985. Subject: Sending Data via TCP
  986. Date: Wed, 6 Nov 1996 20:27:48 GMT
  987. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  988.  
  989. I have a question regarding sending data via TCP.
  990.  
  991. Im trying to write some code which lets users chat with eachother
  992. everything works so far, except for the speed at which it works.
  993.  
  994. I connect to a server, receive data no problem and then when I want
  995. to send 1 char at a time data "key strokes" it takes a long time
  996. to get the confirmation back.  Should I be using some kind of send 
  997. completition routine? or should I be using some kind of queing system 
  998. like telnet?
  999.  
  1000. I send the data (pbcontrolasync) and then monitor the .ioresult field 
  1001. for any errors when it returns without an error I continue.  If I 
  1002. tried sending additional data before the .ioresult came back noerr it 
  1003. would crash.
  1004.  
  1005. what is the easiest way to send data via tcp "async"?  The way im 
  1006. doing it doesnt seem to be async.
  1007.  
  1008. thanks,
  1009.  
  1010. -Edan
  1011.  
  1012. +++++++++++++++++++++++++++
  1013.  
  1014. >From jcz@mgma.com (Jan C. Zawadzki)
  1015. Date: 8 Nov 1996 01:27:17 GMT
  1016. Organization: Internet Express (800-592-1240 customer service)
  1017.  
  1018. In article <3280F4C4.1C56@netcom.com>, edan@netcom.com says...
  1019. >
  1020. >I connect to a server, receive data no problem and then when I want
  1021. >to send 1 char at a time data "key strokes" it takes a long time
  1022. >to get the confirmation back.  Should I be using some kind of send 
  1023. >completition routine? or should I be using some kind of queing system 
  1024. >like telnet?
  1025.  
  1026. What you are seeing is the optimizations in the TCP/IP device driver.  IP 
  1027. packets are large (1000+ bytes), and so sending a byte at a time makes little 
  1028. sense.  The driver maintains a data buffer that you get to fill in, but the 
  1029. decision to send is based on % full and time since first byte arrived.  You 
  1030. have no control over this.  I would recommend redesigning your application to 
  1031. try to cache data.  The other problem is that you are not using the sockets in 
  1032. non-blocking mode.  In "true" asynch mode there is a callback routine that gets 
  1033. triggered when data is available on the pipe.  In that routine you can decide 
  1034. what to do with the data, and your application will appear less "chunky" in 
  1035. execution (ie. you can continually send data, and continually receive data).
  1036.  
  1037. Jan
  1038.  
  1039.  
  1040. +++++++++++++++++++++++++++
  1041.  
  1042. >From "John Dalgliesh" <s2191331@cse.unsw.edu.au>
  1043. Date: 10 Nov 96 20:42:11 +1100
  1044. Organization: University of New South Wales
  1045.  
  1046.  
  1047. --Cyberdog-AltBoundary-00094CE6
  1048. Content-Type: text/plain; charset=ISO-8859-1
  1049. Content-Transfer-Encoding: quoted-printable
  1050.  
  1051. >I have a question regarding sending data via TCP.
  1052. >
  1053. >Im trying to write some code which lets users chat with eachother
  1054. >everything works so far, except for the speed at which it works.
  1055. >
  1056. >I connect to a server, receive data no problem and then when I want
  1057. >to send 1 char at a time data "key strokes" it takes a long time
  1058. >to get the confirmation back.  Should I be using some kind of send 
  1059. >completition routine? or should I be using some kind of queing system
  1060.  
  1061. >like telnet?
  1062. >
  1063. >I send the data (pbcontrolasync) and then monitor the .ioresult field
  1064.  
  1065. >for any errors when it returns without an error I continue.  If I 
  1066. >tried sending additional data before the .ioresult came back noerr it
  1067.  
  1068. >would crash.
  1069. >
  1070. >what is the easiest way to send data via tcp "async"?  The way im 
  1071. >doing it doesnt seem to be async.
  1072.  
  1073. The problem is that MacTCP buffers send requsts, until it's either got
  1074. a certain amount or a certain time has elapsed.
  1075. What you could do is continue regardless of whether there's an error -
  1076. it's no use making an async request if you're going to wait until it's
  1077. complete before proceeding!
  1078. Personally, I just do a sync PBControl nad it seems to work at a
  1079. perfectly acceptable speed.
  1080. Hope this helps!
  1081.  
  1082. {P^/
  1083.  
  1084.  
  1085. --Cyberdog-AltBoundary-00094CE6
  1086. Content-Type: multipart/mixed; boundary="Cyberdog-MixedBoundary-00094CE7"
  1087. Content-Transfer-Encoding: 7bit
  1088.  
  1089.  
  1090. --Cyberdog-MixedBoundary-00094CE7
  1091. Content-Type: text/enriched; charset=ISO-8859-1
  1092. Content-Transfer-Encoding: quoted-printable
  1093.  
  1094. <SMALLER><X-FONTSIZE><PARAM>10</PARAM><FONTFAMILY><PARAM>Geneva</PARAM>=
  1095. >I have a question regarding sending data via TCP.
  1096.  
  1097. >
  1098.  
  1099. >Im trying to write some code which lets users chat with eachother
  1100.  
  1101. >everything works so far, except for the speed at which it works.
  1102.  
  1103. >
  1104.  
  1105. >I connect to a server, receive data no problem and then when I want
  1106.  
  1107. >to send 1 char at a time data "key strokes" it takes a long time
  1108.  
  1109. >to get the confirmation back.  Should I be using some kind of send 
  1110.  
  1111. >completition routine? or should I be using some kind of queing system
  1112.  
  1113.  
  1114. >like telnet?
  1115.  
  1116. >
  1117.  
  1118. >I send the data (pbcontrolasync) and then monitor the .ioresult field
  1119.  
  1120.  
  1121. >for any errors when it returns without an error I continue.  If I 
  1122.  
  1123. >tried sending additional data before the .ioresult came back noerr it
  1124.  
  1125.  
  1126. >would crash.
  1127.  
  1128. >
  1129.  
  1130. >what is the easiest way to send data via tcp "async"?  The way im 
  1131.  
  1132. >doing it doesnt seem to be async.</FONTFAMILY></X-FONTSIZE></SMALLER><=
  1133. SMALLER><X-FONTSIZE><PARAM>10</PARAM><FONTFAMILY><PARAM>Geneva</PARAM>
  1134.  
  1135.  
  1136. The problem is that MacTCP buffers send requsts, until it's either got
  1137. a certain amount or a certain time has elapsed.
  1138.  
  1139. What you could do is continue regardless of whether there's an error -
  1140. it's no use making an async request if you're going to wait until it's
  1141. complete before proceeding!
  1142.  
  1143. Personally, I just do a sync PBControl nad it seems to work at a
  1144. perfectly acceptable speed.
  1145.  
  1146. Hope this helps!
  1147.  
  1148.  
  1149. {P^/</FONTFAMILY></X-FONTSIZE></SMALLER>
  1150. --Cyberdog-MixedBoundary-00094CE7--
  1151.  
  1152. --Cyberdog-AltBoundary-00094CE6--
  1153.  
  1154.  
  1155. +++++++++++++++++++++++++++
  1156.  
  1157. >From nagle@netcom.com (John Nagle)
  1158. Date: Mon, 11 Nov 1996 18:58:32 GMT
  1159. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1160.  
  1161. "John Dalgliesh" <s2191331@cse.unsw.edu.au> writes:
  1162. >--Cyberdog-AltBoundary-00094CE6
  1163. >Content-Type: text/plain; charset=ISO-8859-1
  1164. >Content-Transfer-Encoding: quoted-printable
  1165. >>I have a question regarding sending data via TCP.
  1166. >>Im trying to write some code which lets users chat with eachother
  1167. >>everything works so far, except for the speed at which it works.
  1168. >>
  1169. >>I connect to a server, receive data no problem and then when I want
  1170. >>to send 1 char at a time data "key strokes" it takes a long time
  1171. >>to get the confirmation back.  Should I be using some kind of send 
  1172. >>completition routine? or should I be using some kind of queing system
  1173. >>I send the data (pbcontrolasync) and then monitor the .ioresult field
  1174. >>for any errors when it returns without an error I continue.  If I 
  1175. >>tried sending additional data before the .ioresult came back noerr it
  1176. >>would crash.
  1177. >>
  1178. >>what is the easiest way to send data via tcp "async"?  The way im 
  1179. >>doing it doesnt seem to be async.
  1180.  
  1181. >The problem is that MacTCP buffers send requsts, until it's either got
  1182. >a certain amount or a certain time has elapsed.
  1183.  
  1184.     It's not supposed to do that.  TCP delays ACKs, but not sends
  1185. when the link is idle.  I know; I invented the standard algorithm
  1186. that controls this.  Are synchronous TCP sends waiting for the 
  1187. ACK to come back, or what?  Most TCP implementations return as soon
  1188. as the data has been queued for sending, unless the window is full
  1189. because you've been sending large amounts of data.
  1190.  
  1191.                     John Nagle
  1192.  
  1193. +++++++++++++++++++++++++++
  1194.  
  1195. >From edan@netcom.com
  1196. Date: Wed, 13 Nov 1996 07:53:17 GMT
  1197. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1198.  
  1199. >>I have a question regarding sending data via TCP.
  1200. >>Im trying to write some code which lets users chat with eachother
  1201. >>everything works so far, except for the speed at which it works.
  1202. >>
  1203. >>I connect to a server, receive data no problem and then when I want
  1204. >>to send 1 char at a time data "key strokes" it takes a long time
  1205. >>to get the confirmation back.  Should I be using some kind of send
  1206. >>completition routine? or should I be using some kind of queing system
  1207. >>I send the data (pbcontrolasync) and then monitor the .ioresult field
  1208. >>for any errors when it returns without an error I continue.  If I
  1209. >>tried sending additional data before the .ioresult came back noerr it
  1210. >>would crash.
  1211. >>
  1212. >>what is the easiest way to send data via tcp "async"?  The way im
  1213. >>doing it doesnt seem to be async.
  1214.  
  1215. >The problem is that MacTCP buffers send requsts, until it's either got
  1216. >a certain amount or a certain time has elapsed.
  1217.  
  1218. >    It's not supposed to do that.  TCP delays ACKs, but not sends
  1219. >when the link is idle.  I know; I invented the standard algorithm
  1220. >that controls this.  Are synchronous TCP sends waiting for the
  1221. >ACK to come back, or what?  Most TCP implementations return as soon
  1222. >as the data has been queued for sending, unless the window is full
  1223. >because you've been sending large amounts of data.
  1224.  
  1225. John,  
  1226.  
  1227. I tried everything I could think of, the TCP Send does return, but if you try to 
  1228. send again before it gets an "ECHO" or ACK it will crash.  That is why you have to 
  1229. wait until the .ioResult returns with 0 before you can send again.  That is the 
  1230. problem I am having, I am unable to send keystrokes down the line, so what I did was 
  1231. just buffer the data locally and when it has a few (3 chars) it sends it.
  1232.  
  1233. I think the only way I could see using the async send would be to monitor an abort 
  1234. (ie: command-period) other than that its useless.
  1235.  
  1236. Do you have any other ideas?  thanks!
  1237.  
  1238. -Edan
  1239.  
  1240. +++++++++++++++++++++++++++
  1241.  
  1242. >From fpottier@pauillac.inria.fr (Francois Pottier)
  1243. Date: 13 Nov 1996 10:06:26 GMT
  1244. Organization: INRIA Rocquencourt, BP 105, 78153 Le Chesnay Cedex, France
  1245.  
  1246. In article <32897E6D.1D82@netcom.com>,  <edan@netcom.com> wrote:
  1247.  
  1248. > I tried everything I could think of, the TCP Send does return, but if
  1249. > you try to send again before it gets an "ECHO" or ACK it will crash.
  1250.  
  1251. Of course you can send again, but with a different parameter block...
  1252. That might be your problem.
  1253.  
  1254. --
  1255. Francois Pottier
  1256. Francois.Pottier@inria.fr
  1257. http://pauillac.inria.fr/~fpottier/
  1258.  
  1259. +++++++++++++++++++++++++++
  1260.  
  1261. >From nagle@netcom.com (John Nagle)
  1262. Date: Wed, 13 Nov 1996 19:24:21 GMT
  1263. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1264.  
  1265. fpottier@pauillac.inria.fr (Francois Pottier) writes:
  1266. >In article <32897E6D.1D82@netcom.com>,  <edan@netcom.com> wrote:
  1267. >> I tried everything I could think of, the TCP Send does return, but if
  1268. >> you try to send again before it gets an "ECHO" or ACK it will crash.
  1269. >Of course you can send again, but with a different parameter block...
  1270. >That might be your problem.
  1271.  
  1272.      Right.  That's what I told him in mail.
  1273.  
  1274.      The MacOS has really low-level I/O; it's actually chaining those
  1275. packets of yours into the OS I/O queues, so if you change them
  1276. while I/O is in progress, the I/O system will break.
  1277.  
  1278.                         John Nagle
  1279.  
  1280. ---------------------------
  1281.  
  1282. >From gillga@ilk.de (Peter W. Gillgasch)
  1283. Subject: [Q] Editor for *huge* text files
  1284. Date: Sat, 2 Nov 1996 19:39:48 +0200
  1285. Organization: Organised ? Who ? Me ?
  1286.  
  1287. Hi folks
  1288.  
  1289. I shortly ran into a serious problem, which may sound a bit weird
  1290. but it is real... I need to edit (or at least look at and being
  1291. able to search) text files with sizes of about 500 MB, maybe
  1292. even bigger, say up to 4 GB. Available ram on my machine is 40 mb...
  1293.  
  1294. Any takers ?
  1295.  
  1296. -- Peter
  1297.  
  1298. +++++++++++++++++++++++++++
  1299.  
  1300. >From steve@mindvision.com (Steve Kiene)
  1301. Date: Sun, 03 Nov 1996 11:06:25 -0500
  1302. Organization: MindVision Software
  1303.  
  1304. In article <myers-ya023180000311960945190001@netnews.netaxs.com>,
  1305. myers@netaxs.com (Paul Myers) wrote:
  1306.  
  1307. > In article <55h3ut$m7h@newsbf02.news.aol.com>, jumplong@aol.com (Jump Long)
  1308. > wrote:
  1309. > > Peter W. Gillgasch wrote:
  1310. > > >I shortly ran into a serious problem, which may sound a bit
  1311. > > >weird but it is real... I need to edit (or at least look at and
  1312. > > >being able to search) text files with sizes of about 500 MB,
  1313. > > >maybe even bigger, say up to 4 GB. Available ram on my machine
  1314. > > >is 40 mb...
  1315. > > 
  1316. > > MPW's editor is disk based (not RAM based), so it should be able to handle
  1317. > > files up to the Macintosh's limit. In case you're wondering, the largest
  1318. > > file you can access on a Macintosh is 2Gb.
  1319. > > 
  1320. > No, I think it's up to 4GB with system 7.5, or way up there in the 
  1321. > terabyte range if you have a PCI mac with sys 7.5/
  1322.  
  1323. You are thinking of the maximum volume size, not maximum file size. The
  1324. maximum file size is 2GB. Jim knows.
  1325.  
  1326. Steve Kiene
  1327. MindVision Software
  1328.  
  1329. +++++++++++++++++++++++++++
  1330.  
  1331. >From kirk.pennywitt@gtri.gatech.edu (Kirk Pennywitt)
  1332. Date: Mon, 04 Nov 1996 01:08:33 -0500
  1333. Organization: MindSpring Enterprises
  1334.  
  1335. In article <rang-0311962259200001@tc11-8.msp.spacestar.net>, rang@visi.com
  1336. (Anton Rang) wrote:
  1337.  
  1338. >  Actually, the maximum *volume* size has increased, but the maximum
  1339. >*file* size has not.  (The current File Manager APIs use a signed 32-bit
  1340. >number for both file size and offset, and there may be internal HFS
  1341. >limitations too.)
  1342.  
  1343.  
  1344. Hmm, I didn't know that.  Thanks for the clarification.  I hope someone
  1345. tells Microsoft, before they release Word 7 for the Mac :).
  1346.  
  1347. --kirk
  1348.  
  1349. +++++++++++++++++++++++++++
  1350.  
  1351. >From myers@netaxs.com (Paul Myers)
  1352. Date: Sun, 03 Nov 1996 09:45:19 -0500
  1353. Organization: Net Access - Philadelphia's Original ISP
  1354.  
  1355. In article <55h3ut$m7h@newsbf02.news.aol.com>, jumplong@aol.com (Jump Long)
  1356. wrote:
  1357.  
  1358. > Peter W. Gillgasch wrote:
  1359. > >I shortly ran into a serious problem, which may sound a bit
  1360. > >weird but it is real... I need to edit (or at least look at and
  1361. > >being able to search) text files with sizes of about 500 MB,
  1362. > >maybe even bigger, say up to 4 GB. Available ram on my machine
  1363. > >is 40 mb...
  1364. > MPW's editor is disk based (not RAM based), so it should be able to handle
  1365. > files up to the Macintosh's limit. In case you're wondering, the largest
  1366. > file you can access on a Macintosh is 2Gb.
  1367.  
  1368. No, I think it's up to 4GB with system 7.5, or way up there in the 
  1369. terabyte range if you have a PCI mac with sys 7.5/
  1370.  
  1371. -- 
  1372. Paul Myers                               Department of Biology
  1373. myers@netaxs.com                         Temple University
  1374. http://fishnet.bio.temple.edu/           Philadelphia, PA 19122
  1375.  
  1376. +++++++++++++++++++++++++++
  1377.  
  1378. >From rang@visi.com (Anton Rang)
  1379. Date: Sun, 03 Nov 1996 22:59:20 -0600
  1380. Organization: Spacestar Communications, Minneapolis, MN, USA
  1381.  
  1382. In article <myers-ya023180000311960945190001@netnews.netaxs.com>,
  1383. myers@netaxs.com (Paul Myers) wrote:
  1384. > In article <55h3ut$m7h@newsbf02.news.aol.com>, jumplong@aol.com (Jump Long)
  1385. > wrote:
  1386. > > MPW's editor is disk based (not RAM based), so it should be able to handle
  1387. > > files up to the Macintosh's limit. In case you're wondering, the largest
  1388. > > file you can access on a Macintosh is 2Gb.
  1389. > No, I think it's up to 4GB with system 7.5, or way up there in the 
  1390. > terabyte range if you have a PCI mac with sys 7.5/
  1391.  
  1392.   Actually, the maximum *volume* size has increased, but the maximum
  1393. *file* size has not.  (The current File Manager APIs use a signed 32-bit
  1394. number for both file size and offset, and there may be internal HFS
  1395. limitations too.)
  1396.  
  1397.   -- Anton
  1398.  
  1399. +++++++++++++++++++++++++++
  1400.  
  1401. >From ctate@world.std.com (Christopher L Tate)
  1402. Date: Wed, 13 Nov 1996 17:29:05 GMT
  1403. Organization: The World Public Access UNIX, Brookline, MA
  1404.  
  1405. Kirk Pennywitt (kirk.pennywitt@gtri.gatech.edu) wrote:
  1406. : In article <rang-0311962259200001@tc11-8.msp.spacestar.net>, rang@visi.com
  1407. : (Anton Rang) wrote:
  1408. : >
  1409. : >  Actually, the maximum *volume* size has increased, but the maximum
  1410. : >*file* size has not.  (The current File Manager APIs use a signed 32-bit
  1411. : >number for both file size and offset, and there may be internal HFS
  1412. : >limitations too.)
  1413. :
  1414. : Hmm, I didn't know that.  Thanks for the clarification.  I hope someone
  1415. : tells Microsoft, before they release Word 7 for the Mac :).
  1416.  
  1417. Heh.  Word breaks down into little sobbing fits on *much* smaller
  1418. documents than 2GB.  In fact, getting Word to deal well with 100K
  1419. docs can be an amusing endeavour... if you're watching someone else
  1420. try it....
  1421.  
  1422. -- 
  1423. Christopher Tate (Avara: Magaera)    <*>    ctate@world.std.com
  1424. http://world.std.com/~ctate/         <*>    Finger for PGP public key
  1425.   "0" and "1" - what could possibly be so difficult about that?
  1426.  
  1427. ---------------------------
  1428.  
  1429. >From mieczko1@acsu.buffalo.edu (Mark C Mieczkowski)
  1430. Subject: copybits problem
  1431. Date: 12 Nov 1996 21:41:45 GMT
  1432. Organization: UB
  1433.  
  1434. Hi, 
  1435. I'm having a strange problem with copybits. I'll cut to the chase. Am I doing 
  1436. this right?
  1437.  
  1438. ...
  1439. CopyBits( &(((GrafPtr)offscreenGWorld)->portBits),
  1440.           &(((GrafPtr)projectionWindow)->portBits),
  1441.           &(offscreenGWorld->portRect),
  1442.           &(projectionWindow->portRect),    
  1443.           srcCopy, NIL );
  1444. TIA,
  1445.  
  1446. -Mark
  1447.  
  1448.  
  1449.  
  1450. +++++++++++++++++++++++++++
  1451.  
  1452. >From Jon Karlsson <101745.1122@compuserve.com>
  1453. Date: Thu, 14 Nov 1996 12:06:42 +0100
  1454. Organization: CompuServe Incorporated
  1455.  
  1456. If you're using color, you may need to do this:
  1457.  
  1458. CopyBits( (BitMap*)&(((CGrafPtr)offscreenGWorld)->portPixMap),
  1459.           (BitMap*)&(((GrafPtr)projectionWindow)->portPixMap),
  1460.  
  1461.                                     etc.
  1462.  
  1463. Jon
  1464.  
  1465. +++++++++++++++++++++++++++
  1466.  
  1467. >From mieczko1@acsu.buffalo.edu (Mark C Mieczkowski)
  1468. Date: 13 Nov 1996 20:04:28 GMT
  1469. Organization: UB
  1470.  
  1471. In article <56cnru$o1q@prometheus.acsu.buffalo.edu>,
  1472. Mark C Mieczkowski <mieczko1@acsu.buffalo.edu> wrote:
  1473.  
  1474. >The specific problem is that after the call, my window gets messed up.
  1475. >The window is a noGrowDocProc. After the call to CopyBits, title bar is 
  1476. >multicolored (But not in a good way :), the Title is gone, and the window 
  1477. >borders are gone as well. It seems that I am copying the image over the entire
  1478. >window, including the title bar and borders. I say it seems that way because
  1479. >there is no image on the title bar, it's just a hideous color.
  1480.  
  1481. Okay, I'm miffed! I made no changes to the code, just restarted the computer
  1482. and now everything is working.
  1483.  
  1484. regards and thanks anyway. :)
  1485.  
  1486. -Mark
  1487.  
  1488.  
  1489.  
  1490. ---------------------------
  1491.  
  1492. End of C.S.M.P. Digest
  1493. **********************
  1494.  
  1495.  
  1496.